|
|
|
|
|
|
|
Creating the SQL-VB5 Main Module |
|
|
|
|
|
|
|
|
The SQLVBMOD code module contains the major portion of the system. It's here that you add the routines that can read and execute the SQL statements found in the ASCII file. You also add routines to handle any errors that occur along the way. Even though this module does a lot, you have only slightly more than 10 routines to define before you complete the project. |
|
|
|
|
|
|
|
|
Declaring Global Variables |
|
|
|
|
|
|
|
|
First, you need to declare a set of variables to be used throughout the entire project. These variables contain information about the script being processed, any forms that are open, and so forth. Add a module to the project by selecting Project | Add Module from the Visual Basic main menu. Set its Name property to SQLVBMOD and enter the lines in Listing A.10 into the declarations section. The meaning and use of these variables becomes clearer as you build the various routines within the module. |
|
|
|
|
|
|
|
|
Listing A.10. Adding the global variables. |
|
|
|
|
|
|
|
|
'
' general declarations
'
Global strSQLFile As String
Global intGlobalErr As Integer
Global intSQLFlag As Integer
Global intDBFlag As Integer
Global intSQLFileHandle As Integer
Global strSQLLine As String
Global intLine As Integer
Global strLine As String
Global strGlobalSelect As String
Global strGlobalDBName As String
Global db As Database
Global ws As Workspace
Global intForms As Integer
Global TblForms() As Form
Global strConnect As String
Global strVersion As String
Global blnSQLQuiet As Boolean |
|
|
|
|
|
|
|
|
The top-most routine in this module is the SQLMain routine. This routine has only three tasks: open the script file, process the script commands, and close the script file. Let's write a module that does all that. To add a new procedure to the module, select Tools | Add Procedure from |
|
|
|
|
|